package cloudInformation.controller;

import cloudEntity.entity.SmartClubEntity;
import cloudEntity.leftJoin.ClubPersonLeftJoin;
import cloudEntity.utils.ResultUtils;
import cloudEntity.vo.PageBeanVO;
import cloudInformation.service.SmartClubService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: Smart School
 * @ClassName ClubController
 * @description: 社团控制器
 * @author: 陈智博
 * @create: 2025-05-19 17:32
 * @Version 1.0
 **/
@RestController
@RequestMapping("/club")
@Tag(name = "社团控制器")
public class ClubController {

    @Autowired
    private SmartClubService smartClubService;

    @Operation(summary = "分页查询社团信息")
    @Parameters({
            @Parameter(name = "t",description = "社团名字",required = false),
            @Parameter(name = "n",description = "页码",required = false),
            @Parameter(name = "s",description = "条数",required = false)
    })
    @RequestMapping("/get/page")
    public ResultUtils getClubPage(
                @RequestParam(value = "t",required = false,defaultValue = "") String clubName,
                @RequestParam(value = "n",required = false,defaultValue = "1") Integer pageNum,
                @RequestParam(value = "s",required = false,defaultValue = "5") Integer pageSize)
    {
        PageBeanVO<SmartClubEntity> smartNewsDTOPageBeanVO = smartClubService.GetClubByPage(clubName, pageNum, pageSize);
        return ResultUtils.success(smartNewsDTOPageBeanVO);
    }

    @Operation(summary = "根据社团id,查询社团成员")
    @Parameters({
            @Parameter(name = "t",description = "社团id",required = true),
            @Parameter(name = "n",description = "页码",required = false),
            @Parameter(name = "s",description = "条数",required = false)
    })
    @RequestMapping("/get/byId")
    public ResultUtils getClubById( @RequestParam(value = "t",required = true,defaultValue = "") String clubIds,
                                    @RequestParam(value = "n",required = false,defaultValue = "1") Integer pageNum,
                                    @RequestParam(value = "s",required = false,defaultValue = "10") Integer pageSize)
    {
        PageBeanVO<ClubPersonLeftJoin> clubPersonLeftJoins = smartClubService.GetClubByIds(clubIds,pageNum,pageSize);
        return ResultUtils.success(clubPersonLeftJoins);
    }

}
